<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddColumnBookWord250910 extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('book_word', function (Blueprint $table){
            $table->string('error_syllable')->default('')->comment('错误音节');
        });

        //用户打卡签到
        Schema::create('user_sign', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->default(0)->comment('用户ID');
            $table->string('year_month')->default('202509')->comment('年月');
            $table->date('date')->index()->default('2025-09-10')->comment('日期');
            $table->integer('status')->default(1)->comment('是否打卡');
            $table->timestamps();

            $table->unique(['user_id','year_month', 'date']);
        });

        //用户订阅
        Schema::create('user_subscribe', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->index()->default(0)->comment('用户ID');
            $table->string('template_id')->index()->default('')->comment('模板ID');
            $table->date('date')->index()->default('2025-09-10')->comment('日期');
            $table->integer('type')->default(0)->comment('类型：0、首页 1、10单词 2、20单词 3、30单词');
            $table->integer('status')->default(0)->comment('订阅状态：0、弹窗 1、点击  2、订阅成功');
            $table->timestamps();

            $table->index(['date','type','status']);
        });


        //日报表
        Schema::create('daily_report', function (Blueprint $table) {
            $table->increments('id');
            $table->date('date')->unique()->default('2025-09-10')->comment('日期');
            $table->integer('fir_sub_click')->default(1)->comment('首页订阅按钮点击人数');
            $table->integer('fir_sub_sub')->default(1)->comment('订阅人数');

            $table->integer('one_sub_pop')->default(1)->comment('订阅弹窗-10词触发人数');
            $table->integer('one_sub_click')->default(1)->comment('点击人数');
            $table->integer('one_sub_sub')->default(1)->comment('订阅人数');

            $table->integer('two_sub_pop')->default(1)->comment('订阅弹窗-20词触发人数');
            $table->integer('tow_sub_click')->default(1)->comment('点击人数');
            $table->integer('two_sub_sub')->default(1)->comment('订阅人数');

            $table->integer('thr_sub_pop')->default(1)->comment('订阅弹窗-30词触发人数');
            $table->integer('thr_sub_click')->default(1)->comment('点击人数');
            $table->integer('thr_sub_sub')->default(1)->comment('订阅人数');
            $table->timestamps();
        });

        //事件明细
        Schema::create('event_details', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->default(0)->comment('用户ID');
            $table->date('date')->default('2025-09-10')->comment('日期');
            $table->integer('type')->default(0)->comment('事件类型');
            $table->timestamps();

            $table->unique(['user_id', 'date']);
        });


    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}
